/**
 * 
 */
package cn.gov.msa.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import cn.gov.msa.dao.NavigationMarkMapper;
import cn.gov.msa.dao.WaterwayMapper;
import cn.gov.msa.model.NavigationMark;
import cn.gov.msa.model.Waterway;
import cn.gov.msa.service.WaterwayService;
import net.sf.json.JSONObject;

/**
 * @author Administrator
 *
 */
public class WaterwayServiceImpl implements WaterwayService {

	@Autowired
	private WaterwayMapper waterwayMapper;
	@Autowired
	private NavigationMarkMapper navigationMarkMapper;
	
	@Transactional
	@Override
	public boolean saveMark(String waterwaycode, List<NavigationMark> navigationMarkList) throws Exception {
		boolean save = false;
		int i = 0;

    	navigationMarkMapper.deleteByWaterwaycode(waterwaycode);
    	
    	for (NavigationMark navigationMark : navigationMarkList) {
    		
			i = navigationMarkMapper.insert(navigationMark);
		} 
    	
    	save = i > 0?true:false;
		
		return save;
	}

	@Override
	public List<Waterway> getWaterwayList(Waterway waterway) throws Exception {
		
		List<Waterway> waterwayList = waterwayMapper.selectData(waterway);
		
		return waterwayList;
	}

	@Override
	public List<NavigationMark> getMarkList(NavigationMark navigationMark) throws Exception {
		
		String waterwaycode = navigationMark.getWaterwaycode();

		List<NavigationMark> navigationMarkList = navigationMarkMapper.selectByWaterwaycode(waterwaycode);
		
		return navigationMarkList;
	}

}
